<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    private $_model,$_view;

    /**
     * IndexController constructor.
     */
    public function __construct()
    {
        parent::__construct();
        $this->_model = new \Home\Model\ListModel();
    }

    public function index(){
        $type = I('type')==null?0:I('type');
            //选择tab标签
            $tab = array('','','','');
            if($type==0){
                $tab[0] = 'active';
            }else if($type==1){
                $tab[1] = 'active';
            }else if($type==2){
                $tab[2] = 'active';
            }else if($type==3){
            $tab[3] = 'active';
        }
        $this->assign('tab',$tab);
        $this->assign('type',$type);
        $this->display();
    }
    //搜索栏
    public function serach(){
		// $this->_view = D('SearchView');
        $s['title'] = array('like','%'.I('serach').'%');
        $data = $this->_model->where($s)->limit(0,15)->select();
		// print_r($this->_view->getDbError());
        $this->ajaxReturn($data);
    }
    //搜索结果页面
    public function serach_page(){
        $s['title'] = array('like','%'.I('serData').'%');
        $data = $this->_model->where($s)->limit(0,15)->select();
        $this->assign('data',$data);
        $this->display('serach');
    }
    //视频信息列表
    public function lis(){
        $id = I('id');
        $tar = $this->_model->selec($id);
        $this->assign('tar',$tar[0]);
        $this->assign('list',$tar[1]);
        $this->display();
    }
    //观看视频页面
    public function film(){
        $id = I('id');
        $tar=$this->_model->find($id);
        $this->assign('tar',$tar);
        $this->display();
    }
    //ajax动态数据获取
    //动画
    public function ajax_carton(){

        $carton = $this->_model->carton(I('id'),16);
        if($carton!=null){
            $this->ajaxReturn($carton);
        }else{
            $this->ajaxReturn(-1);
        }
    }
    //电影
    public function ajax_movie(){
        $movie = $this->_model->movice(I('id'),16);
        if($movie!=null){
            $this->ajaxReturn($movie);
        }else{
            $this->ajaxReturn(-1);
        }
    }
    //电视剧
    public function ajax_tv(){
        $tv = $this->_model->tv(I('id'),16);
        if($tv!=null){
            $this->ajaxReturn($tv);
        }else{
            $this->ajaxReturn(-1);
        }
    }
}